import re

split_re = re.compile('[.?!]')

def find_sentences(text):
    idx = 0
    while idx < len(text):
        match = split_re.search(text, idx)
        if match is None:
            yield text[idx:].strip()
            idx = len(text)
        else:
            yield text[idx:match.end()].strip()
            idx = match.end() + 1

def test():
    sentences = ['Hello, how are you?',
                 'I am fine.',
                 'This is pretty cool!']
    for idx,sen in enumerate(find_sentences(' '.join(sentences))):
        assert sen == sentences[idx]
    
if __name__ == '__main__':
    test()
